package com.example.jumpnote.android.server;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.android.c2dm.server.C2DMRetryServlet;

public class RegisterService extends HttpServlet{
	private static final long serialVersionUID = 6630849947825742571L;
	private static final Logger log = Logger.getLogger(C2DMRetryServlet.class.getName());
	protected void doPost (HttpServletRequest req, HttpServletResponse resp) throws ServletException,
    IOException {
		String email = req.getParameter("email");
		String deviceId = req.getParameter("deviceId");
		String registrationId = req.getParameter("registrationId");
		if(email!=null&&deviceId!=null&&registrationId!=null){
			RegistrationInfo reg=new RegistrationInfo();
			reg.setAccountName(email);
			reg.setDeviceId(deviceId);
			reg.setDeviceRegistrationId(registrationId);
			reg.register();
		}
        resp.sendRedirect("/Users.jsp");
      }
	protected void doGet (HttpServletRequest req, HttpServletResponse resp){
		try {
			this.doPost(req, resp);
		} catch (ServletException e) {
			log.info("ServletException:"+e.getMessage());
			e.printStackTrace();
		} catch (IOException e) {
			log.info("IOException:"+e.getMessage());
			e.printStackTrace();
		}
	}
}

